<?php
abstract class BaseController {
	protected $baseName;
	protected $action;
	protected $model;
	public function __construct($baseName, $action) {
		$this->baseName = $baseName;
		$this->action = $action;
	}
	public function executeAction() {
		return $this->{($this->action) . ($_POST != [ ] ? 'Post' : 'Get')} ();
	}
	protected function returnView($d = [], $enmarcado = true, $fVista = '') {
		if ($fVista == '') {
			$fVista = 'view/' . $this->baseName . '/' . $this->action . ($_POST != [ ] ? 'Post' : 'Get') . '.php';
		}
		require_once ($fVista);
	}
	protected function createModel($nombreBase = '') {
		if ($nombreBase == '') {
			$nombreBase = $this->baseName;
		}
		
		$fModelo = 'model/' . $nombreBase . 'Model.class.php';
		if (file_exists ( $fModelo )) {
			require_once ($fModelo);
			$clase = $nombreBase . 'Model';
			$this->model = new $clase ();
		} else {
			echo "Modelo inexistente"; // TODO
		}
	}
}
?>